package com.apps.ftapp.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.apps.ftapp.R;

import java.util.List;

/**
 * Created by Lly on 2017/10/11.
 */

public class SubjectMoreGridAdapter extends BaseAdapter {


    private Context mContext;
    private List<String> titles;

    public SubjectMoreGridAdapter(Context mContext, List<String> dataList) {
        super();
        this.mContext = mContext;
        this.titles = dataList;
    }

    @Override
    public int getCount() {
        if (null == titles) {
            return 0;
        } else {
            return this.titles.size();
        }
    }

    @Override
    public Object getItem(int i) {
        if (titles == null) {
            return null;
        } else {
            return this.titles.get(i);
        }
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        String tit = titles.get(i);
        ViewHolder holder = null;
        if (view == null) {
            view = LayoutInflater.from(this.mContext).inflate(R.layout.activity_subject_more_gridview_item, null, false);
            holder = new ViewHolder(view);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        holder.textView.setText(tit);
        return view;
    }


    private class ViewHolder {
        TextView textView;

        public ViewHolder(View view) {
            textView = view.findViewById(R.id.sel_text);
        }
    }


}
